package org.acra.d;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Iterator;
import java.util.Locale;
import java.util.Set;
import org.acra.ACRA;
import org.acra.ReportField;
import org.acra.b.c;
import org.acra.c.a;
import org.json.JSONException;
import org.json.JSONObject;

public class g
{
  private static Object a(String paramString)
  {
    if (paramString.equalsIgnoreCase("true"))
      paramString = Boolean.valueOf(true);
    do
    {
      return paramString;
      if (paramString.equalsIgnoreCase("false"))
        return Boolean.valueOf(false);
    }
    while (!paramString.matches("(?:^|\\s)([1-9](?:\\d*|(?:\\d{0,2})(?:,\\d{3})*)(?:\\.\\d*[1-9])?|0?\\.\\d*[1-9]|0)(?:\\s|$)"));
    NumberFormat localNumberFormat = NumberFormat.getInstance(Locale.US);
    try
    {
      Number localNumber = localNumberFormat.parse(paramString);
      return localNumber;
    }
    catch (ParseException localParseException)
    {
    }
    return paramString;
  }

  public static JSONObject a(c paramc)
  {
    JSONObject localJSONObject1 = new JSONObject();
    Iterator localIterator = paramc.keySet().iterator();
    while (localIterator.hasNext())
    {
      ReportField localReportField = (ReportField)localIterator.next();
      try
      {
        if (localReportField.containsKeyValuePairs())
        {
          JSONObject localJSONObject2 = new JSONObject();
          BufferedReader localBufferedReader = new BufferedReader(new StringReader(paramc.a(localReportField)), 1024);
          try
          {
            while (true)
            {
              String str = localBufferedReader.readLine();
              if (str == null)
                break;
              a(localJSONObject2, str);
            }
          }
          catch (IOException localIOException)
          {
            ACRA.log.b(ACRA.LOG_TAG, "Error while converting " + localReportField.name() + " to JSON.", localIOException);
            localJSONObject1.accumulate(localReportField.name(), localJSONObject2);
          }
        }
      }
      catch (JSONException localJSONException)
      {
        throw new h("Could not create JSON object for key " + localReportField, localJSONException);
      }
      localJSONObject1.accumulate(localReportField.name(), a(paramc.a(localReportField)));
    }
    return localJSONObject1;
  }

  private static void a(JSONObject paramJSONObject, String paramString)
  {
    int i = paramString.indexOf('=');
    if (i > 0)
    {
      String str = paramString.substring(0, i).trim();
      Object localObject = a(paramString.substring(i + 1).trim());
      String[] arrayOfString = str.split("\\.");
      if (arrayOfString.length > 1)
      {
        a(paramJSONObject, arrayOfString, localObject);
        return;
      }
      paramJSONObject.accumulate(str, localObject);
      return;
    }
    paramJSONObject.put(paramString.trim(), true);
  }

  private static void a(JSONObject paramJSONObject, String[] paramArrayOfString, Object paramObject)
  {
    int i = 0;
    if (i < paramArrayOfString.length)
    {
      String str = paramArrayOfString[i];
      JSONObject localJSONObject;
      if (i < -1 + paramArrayOfString.length)
        if (paramJSONObject.isNull(str))
        {
          localJSONObject = new JSONObject();
          paramJSONObject.accumulate(str, localJSONObject);
          label48: paramJSONObject = localJSONObject;
        }
      while (true)
      {
        i++;
        break;
        localJSONObject = paramJSONObject.getJSONObject(str);
        break label48;
        paramJSONObject.accumulate(str, paramObject);
      }
    }
  }
}

/* Location:           D:\Studium\Bachelorarbeit\BA Marcus Wobig\BA\BA\Decompiler\PicturePassword APK\Programm\PicturePassword_dex2jar.jar
 * Qualified Name:     org.acra.d.g
 * JD-Core Version:    0.6.2
 */